<?php
require_once 'Display/DisplayInterface.php';
require_once 'Observer/ObserverInterface.php';
require_once 'Subject/SubjectInterface.php';
require_once 'Observer/Observer.php';

require_once 'Observer/HunanObserver.php';
require_once 'Observer/HebeiObserver.php';
require_once 'Display/XmlDisplay.php';
require_once 'Display/JsonDisplay.php';
require_once 'Subject/WeatherSubject.php';
/**
 * 客户端
 */
//主题：气象天气
$weather = new WeatherSubject();
//湖南需要监听湿度，并json格式显示
$hunan = new HunanObserver('湖南卫视', new JsonDisplay());
$weather->registerObserver($hunan);

//河北需要监听温度，并xml格式显示
$hebei = new HebeiObserver('河北卫视', new XmlDisplay());
$weather->registerObserver($hebei);

//气象站检测到 温度和湿气改变
$weather->setChange();
$weather->setTemperature(27.11);
$weather->setChange();
$weather->setHumidity(0.6);